package com.yjy.fuyao.stu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yjy.fuyao.stu.entity.Comment;
import com.yjy.fuyao.stu.mapper.CommentMapper;
import com.yjy.fuyao.stu.service.CommentService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 评论 服务实现类
 * </p>
 *
 * @author yjy
 * @since 2021-08-25
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Override
    public Comment getCourseRate(String courseId, String userId) {
        LambdaQueryWrapper<Comment> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Comment::getCourseId,courseId)
                .eq(Comment::getUserId,userId)
                .ne(Comment::getRate,-1);
        return baseMapper.selectOne(queryWrapper);
    }
}
